﻿<%@ Page Language="C#" AutoEventWireup="true"  Inherits="GovernmentOfficeProject.common.view.ViewPageBase" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>正镶白旗政府办自动化系统</title>
    <link rel="stylesheet" type="text/css" href="/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="/lib/easyui/themes/default/easyui.css"/>
	<script src="/lib/easyui/jquery-1.8.0.min.js" type="text/javascript"></script>  
	<script type="text/javascript" src="/lib/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript">
	    
	    var data = <%=new GovernmentOfficeProject.LevelBusinessLogic.BLL_SYSTEM().GetMenuListByUserToJson(GovernmentOfficeProject.SysTools.SystemContext.CurrentUserID)%>;
	    /*
	    {
	        "rootMenu": [{ "MenuName": "日程管理", "MenuNo": "calendar" }, { "MenuName": "通迅管理", "MenuNo": "info" }, { "MenuName": "系统管理", "MenuNo": "system"}],
	        "menuDetails": {
	            "calendar": { "MenuName": "日程管理", "MenuNo": "calendar", "childrens": [{ "MenuName": "个人日程", "MenuNo": "mycalendar" }, { "MenuName": "领导日程", "MenuNo": "ldcalendar"}] },
	            "info": { "MenuName": "通迅管理", "MenuNo": "info", "childrens": [{ "MenuName": "联系人", "MenuNo": "mycalendar"}] },
	            "system": { "MenuName": "系统管理", "MenuNo": "system", "childrens": [{ "MenuName": "基本信息", "MenuNo": "mycalendar"}] }
	        }
	    };
        */
        
	    var selectedMenu;

	    $(document).ready(function () {
	        var menuList = data.rootMenu;
	        var html = [];
	        var first = true;

	        //默认选择菜单
	        selectedMenu = menuList[0].MenuNo;

	        //初始化主菜单
	        for (var i = 0; i < menuList.length; i++) {
	            html.push("<li name=\"");
	            html.push(menuList[i].MenuNo);
	            html.push("\"><a href=\"#\">");
	            html.push(menuList[i].MenuName);
	            html.push("</a></li>");
	            //初始化第一个主菜单的子菜单
	            if (i == 0 && data.menuDetails[menuList[i].MenuNo].childrens != null) {
	                initLeftMenu(data.menuDetails[menuList[i].MenuNo].childrens);
	            }

	        }
	        $("#menu ul").html(html.join(""));
	        html = [];

	        //添加菜单点击事件-- 初始化子菜单
	        $("#menu li").click(function () {
	            first = false;
	            initLeftMenu(data.menuDetails[$(this).attr("name")].childrens);
	        });

	        //初始化左边菜单
	        function initLeftMenu(menuArr) {
	            var submenuHtml = [];
	            var submenu = menuArr;
	            
			    if($('#aa').accordion('panels').length > 0){
			        $('#aa').accordion('remove',0);
			    }
			    
	            if (submenu != null) {
	                for (var j = 0; j < submenu.length; j++) {
	                    if(submenu[j].MenuName == '领导日程'){
	                        var ldChildrens = submenu[j].childrens;
	                        if(ldChildrens.length == 0)continue;
	                        ldSubHtml = [];
	                        for(var i = 0;i< ldChildrens.length;i++){
	                            ldSubHtml.push("<a href=\"javascript:void(0)\" onclick=\"open1('"+ldChildrens[i].MenuName+"','"+ldChildrens[i].url+"')\" class=\"easyui-linkbutton\" data-options=\"plain:true\" style=\"margin-top:2px;width:92%;\">"+ldChildrens[i].MenuName+"</a>");	                          
	                        }
	                        
	                        $('#aa').accordion('add', {
	                            title: '领导日程',
	                            content: ldSubHtml.join(''),
	                            selected: false
                            });
                            ldSubHtml = [];
	                        
	                    }else{
	                        var url = submenu[j].url+"?menuNo="+submenu[j].MenuNo;
	                     
	                        if (j == 0 && !first) {
	                            $("#frame").attr("src", url);
	                            $("#mainDiv").panel({title:submenu[j].MenuName});
	                        }
	                        submenuHtml.push("<div id=\"subMenu\" name=\"");
	                        submenuHtml.push(url);
	                        submenuHtml.push("\">")
	                        submenuHtml.push(submenu[j].MenuName);
	                        submenuHtml.push("</div>");
	                    }
	                    
	                }
	                $("#leftMenu").html(submenuHtml.join(""));
	                submenuHtml = null;
	            }
	            
	             $("#leftMenu div").click(function () { 
                    var url = $(this).attr("name");
                    var titleStr = this.innerHTML;
                    $("#frame").attr("src", url);
                    $("#mainDiv").panel({title:titleStr});
                    
                });
	        }	      
	    });
	    function open1(title,url){
	         $("#frame").attr("src", url);
             $("#mainDiv").panel({title:"领导日程-"+title});
	    }
	    
    </script>
</head>
	
<body class="easyui-layout" id="layout">
    <div data-options="region:'north',border:false" style="height:83px;padding:0px">
         <div id="top">
       	  <div id="userInfo">
            <span>欢迎用户 
            <%=GovernmentOfficeProject.SysTools.SystemContext.CurrentUserTitle %> 登录</span>
            <span><a href="handler/Validate.ashx?Action=Logout" id="logout">注销</a></span>
          </div>
           <div id="menu">
                <ul>
                
                </ul>
          </div>
    	</div>
      </div>
	<div  data-options="region:'west',split:true,title:'菜单'" style="width:200px;padding:0px; overflow:hidden;">
        <div id="leftMenu">
            
        </div>
        <div id="aa" class="easyui-accordion" data-options="fit:true,border:false">
			
        </div>
        
    </div>
	<div data-options="region:'south',border:false" id="footer">Copyright©2012-2013</div>
	<div data-options="region:'center',title:'欢迎'" id="mainDiv" style="overflow-x:hidden;overflow-y:hidden">
	     <iframe id="frame" frameborder="0" style=" margin-left:-1px;"  scrolling="no" src="welcome.htm" width="100%" height="100%"></iframe> 
	</div>
</body>
</html>
